package com.md24housecall.manager;

import java.util.ArrayList;
import java.util.List;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.md24housecall.model.CategoryPartner;
import com.md24housecall.model.IHealthDataList;
import com.md24housecall.model.Partner;
import com.md24housecall.util.GlobalConstant;
import com.md24housecall.util.MyLog;

public class CacheManager {
	private static SQLiteDatabase sqldb;
	private static CacheManager mInstance;
	private final String IDKEY="PartnerId";
	private final String NAMEKEY="name";
	private final String DESCRIPTIONKEY="description";
	private final String SHORTDESCRIPTIONKEY="shortDescription";
	private final String WEBSITEKEY="website";
	private final String EMAILKEY="email";
	private final String PHONEKEY="phone";
	private final String LOGOKEY="logo";
	private final String LOGOURLKEY="logoUrl";
	private final String PRIORITYKEY="priority";
	private final String CATEGORYIDKEY="categoryId";
	private final String SKYPEKEY="skypeName";
	private final String IMAGEURLKEY="imageUrl";
	private final String LAST_CHANGEKEY="last_change";
	private final String MDATEKEY="mdate";
	private final String HPKEY="HP";
	private final String LPKEY="LP";
	private final String HRKEY="HR";
	private final String WEIGHKEY="Weight";
	private final String BMIKEY="BMI";
	private final String DCIKEY="DCI";
	private final String BGKEY="BG";
	private final String DINNERSITUATIONKEY="DinnerSituation";
	private final String DRUGSITUATIONKEY="DrugSituation";
	private final String BOKEY="BO";
	private final String CALORIESKEY="Calories";
	private final String DISTANCETRAVELLEDKEY="DistanceTraveled";
	private final String STEPSKEY="Steps";
	public final static String DATABASE_NAME="telemedicine";

	public CacheManager() {
	}

	public boolean isOpen(){
		return sqldb.isOpen();
	}
	
	public void close() {
		if (sqldb.isOpen()) {
			sqldb.close();
		}
	}

	public int getTotalPartnerCategory(){
		String sql="select count(*) from category_partner";
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(sql,null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					cursor.moveToFirst();
					return cursor.getInt(0);
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception getTotalPartnerCategory: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return 0;
	}
	
	public int getTotalPartners(){
		String sql="select count(*) from partner";
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(sql,null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					cursor.moveToFirst();
					return cursor.getInt(0);
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception getTotalPartner: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return 0;
	}
	
	public int getTotalPartnersByCategory(String categoryId){
		String sql="select count(*) from partner where categoryId='%s'";
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(String.format(sql, categoryId),null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					cursor.moveToFirst();
					return cursor.getInt(0);
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception getTotalPartnersByCategory: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return 0;
	}
	public void clearPartnerData(){
		if (sqldb != null && sqldb.isOpen()){
			sqldb.execSQL("DELETE FROM partner");
		}
	}
	
	public void clearCategoryPartnerData(){
		if (sqldb != null && sqldb.isOpen()){
			sqldb.execSQL("DELETE FROM category_partner");
		}
	}
	
	public List<CategoryPartner> selectPartnerCategories(int start,int limit){
		String sql="select * from category_partner order by priority asc limit %s offset %s";
		MyLog.d(GlobalConstant.TAG, "sql category: "+String.format(sql, ""+limit,""+start));
		List<CategoryPartner> listPartner=null;
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(String.format(sql, ""+limit,""+start), null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					listPartner=new ArrayList<CategoryPartner>(cursor.getCount());
					cursor.moveToFirst();
					while(!cursor.isAfterLast()){
						CategoryPartner category=new CategoryPartner();
						category.setId(""+cursor.getInt(0));
						category.setName(cursor.getString(1));
						category.setLogoUrl(cursor.getString(2));
						category.setShortDescription(cursor.getString(3));
						category.setPriority(cursor.getInt(4));
						listPartner.add(category);
						cursor.moveToNext();
					}
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception selectPartnerCategories: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return listPartner;
		
	}
	
	public List<Partner> selectPartners(int start,int limit,String categoryId){
		String sql="select * from partner where categoryId='%s' order by priority asc limit %s offset %s";
		MyLog.d(GlobalConstant.TAG, "sql partner detail: "+String.format(sql,categoryId, ""+limit,""+start));
		List<Partner> listPartner=null;
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(String.format(sql,categoryId, ""+limit,""+start), null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					listPartner=new ArrayList<Partner>(cursor.getCount());
					cursor.moveToFirst();
					while(!cursor.isAfterLast()){
						Partner partner=new Partner();
						partner.setId(""+cursor.getInt(0));
						partner.setName(cursor.getString(1));
						partner.setDescription(cursor.getString(2));
						partner.setShortDescription(cursor.getString(3));
						partner.setWebsite(cursor.getString(4));
						partner.setEmail(cursor.getString(5));
						partner.setPhone(cursor.getString(6));
						partner.setLogo(cursor.getString(7));
						partner.setImageUrl(cursor.getString(8));
						partner.setCategoryId(cursor.getInt(9));
						partner.setSkypeName(cursor.getString(10));
						partner.setPriority(cursor.getInt(11));
						listPartner.add(partner);
						cursor.moveToNext();
					}
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception selectPartners: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return listPartner;
		
	}
	
	public void insertPartner(Partner partner){
		ContentValues values = new ContentValues();
		values.put(IDKEY, partner.getId());
		values.put(NAMEKEY, partner.getName());
		values.put(DESCRIPTIONKEY, partner.getDescription());
		values.put(SHORTDESCRIPTIONKEY, partner.getShortDescription());
		values.put(WEBSITEKEY, partner.getWebsite());
		values.put(EMAILKEY, partner.getEmail());
		values.put(PHONEKEY, partner.getPhone());
		values.put(LOGOKEY, partner.getLogo());
		values.put(IMAGEURLKEY, partner.getImageUrl());
		values.put(CATEGORYIDKEY, partner.getCategoryId());
		values.put(SKYPEKEY, partner.getSkypeName());
		values.put(PRIORITYKEY, partner.getPriority());
		sqldb.insert("partner", null, values);
	}
	
	public void insertCategoryPartner(CategoryPartner category){
		ContentValues values = new ContentValues();
		values.put(CATEGORYIDKEY, category.getId());
		values.put(NAMEKEY, category.getName());
		values.put(SHORTDESCRIPTIONKEY, category.getShortDescription());
		values.put(LOGOURLKEY, category.getLogoUrl());
		values.put(PRIORITYKEY, category.getPriority());
		sqldb.insert("category_partner", null, values);
	}
	/*start: blood pressure*/
	public void insertBloodPressure(IHealthDataList bpData){
		ContentValues values = new ContentValues();
		values.put(HPKEY, bpData.getHP());
		values.put(LPKEY, bpData.getLP());
		values.put(HRKEY, bpData.getHR());
		values.put(MDATEKEY, bpData.getDate());
		values.put(LAST_CHANGEKEY, bpData.getLastChangeTime());
		sqldb.insert("blood_pressure", null, values);
	}
	
	public void clearBloodPressureData(){
		if (sqldb != null && sqldb.isOpen()){
			sqldb.execSQL("DELETE FROM blood_pressure");
		}
	}
	
	public int getTotalBloodPressure(){
		String sql="select count(*) from blood_pressure";
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(sql,null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					cursor.moveToFirst();
					return cursor.getInt(0);
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception getTotalBloodPressure: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return 0;
	}
	
	public List<IHealthDataList> selectBloodPressure(int start,int limit){
		String sql="select * from blood_pressure order by MDate desc limit %s,%s";
		List<IHealthDataList> listBPData=null;
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(String.format(sql,""+start, ""+limit), null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					listBPData=new ArrayList<IHealthDataList>(cursor.getCount());
					cursor.moveToFirst();
					while(!cursor.isAfterLast()){
						IHealthDataList bpData=new IHealthDataList();
						bpData.setHP(cursor.getInt(1));
						bpData.setLP(cursor.getInt(2));
						bpData.setHR(cursor.getInt(3));
						bpData.setDate(cursor.getInt(4));
						bpData.setLastChangeTime(cursor.getInt(5));
						listBPData.add(bpData);
						cursor.moveToNext();
					}
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception select blood pressure: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return listBPData;
		
	}
	/*end: blood pressure*/
	
	/*start: weight*/
	public void insertWeight(IHealthDataList weightData){
		ContentValues values = new ContentValues();
		values.put(WEIGHKEY, weightData.getWeightValue());
		values.put(BMIKEY, weightData.getBMI());
		values.put(DCIKEY, weightData.getDCI());
		values.put(MDATEKEY, weightData.getDate());
		values.put(LAST_CHANGEKEY, weightData.getLastChangeTime());
		sqldb.insert("weight", null, values);
	}
	
	public void clearWeightData(){
		if (sqldb != null && sqldb.isOpen()){
			sqldb.execSQL("DELETE FROM weight");
		}
	}
	
	public int getTotalWeight(){
		String sql="select count(*) from weight";
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(sql,null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					cursor.moveToFirst();
					return cursor.getInt(0);
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception getTotalweight: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return 0;
	}
	
	public List<IHealthDataList> selectWeight(int start,int limit){
		String sql="select * from weight order by MDate desc limit %s,%s";
		List<IHealthDataList> listWeightData=null;
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(String.format(sql,""+start, ""+limit), null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					listWeightData=new ArrayList<IHealthDataList>(cursor.getCount());
					cursor.moveToFirst();
					while(!cursor.isAfterLast()){
						IHealthDataList weightData=new IHealthDataList();
						weightData.setWeightValue(cursor.getDouble(1));
						weightData.setBMI(cursor.getDouble(2));
						weightData.setDCI(cursor.getInt(3));
						weightData.setDate(cursor.getInt(4));
						weightData.setLastChangeTime(cursor.getInt(5));
						listWeightData.add(weightData);
						cursor.moveToNext();
					}
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception select weight: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return listWeightData;
		
	}
	/*end: weight*/
	
	/*start: blood gluco*/
	public void insertGluco(IHealthDataList glucoData){
		ContentValues values = new ContentValues();
		values.put(BGKEY, glucoData.getGlucoValue());
		values.put(DINNERSITUATIONKEY, glucoData.getDinnerSituation());
		values.put(DRUGSITUATIONKEY, glucoData.getDrugSituation());
		values.put(MDATEKEY, glucoData.getDate());
		values.put(LAST_CHANGEKEY, glucoData.getLastChangeTime());
		sqldb.insert("gluco", null, values);
	}
	
	public void clearGlucoData(){
		if (sqldb != null && sqldb.isOpen()){
			sqldb.execSQL("DELETE FROM gluco");
		}
	}
	
	public int getTotalGluco(){
		String sql="select count(*) from gluco";
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(sql,null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					cursor.moveToFirst();
					return cursor.getInt(0);
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception getTotalgluco: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return 0;
	}
	
	public List<IHealthDataList> selectGluco(int start,int limit){
		String sql="select * from gluco order by MDate desc limit %s,%s";
		List<IHealthDataList> listGlucoData=null;
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(String.format(sql,""+start, ""+limit), null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					listGlucoData=new ArrayList<IHealthDataList>(cursor.getCount());
					cursor.moveToFirst();
					while(!cursor.isAfterLast()){
						IHealthDataList glucoData=new IHealthDataList();
						glucoData.setGlucoValue(cursor.getInt(1));
						glucoData.setDinnerSituation(cursor.getString(2));
						glucoData.setDrugSituation(cursor.getString(3));
						glucoData.setDate(cursor.getInt(4));
						glucoData.setLastChangeTime(cursor.getInt(5));
						listGlucoData.add(glucoData);
						cursor.moveToNext();
					}
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception select gluco: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return listGlucoData;
		
	}
	/*end: blood gluco*/
	
	/*start: blood oxygen*/
	public void insertBloodOxygen(IHealthDataList oxygenData){
		ContentValues values = new ContentValues();
		values.put(BOKEY, oxygenData.getBloodOxygen());
		values.put(HRKEY, oxygenData.getHR());
		values.put(MDATEKEY, oxygenData.getDate());
		values.put(LAST_CHANGEKEY, oxygenData.getLastChangeTime());
		sqldb.insert("blood_oxygen", null, values);
	}
	
	public void clearBloodOxygenData(){
		if (sqldb != null && sqldb.isOpen()){
			sqldb.execSQL("DELETE FROM blood_oxygen");
		}
	}
	
	public int getTotalBloodOxygen(){
		String sql="select count(*) from blood_oxygen";
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(sql,null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					cursor.moveToFirst();
					return cursor.getInt(0);
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception getTotalblood_oxygen: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return 0;
	}
	
	public List<IHealthDataList> selectBloodOxygen(int start,int limit){
		String sql="select * from blood_oxygen order by MDate desc limit %s,%s";
		List<IHealthDataList> listBloodOxygen=null;
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(String.format(sql,""+start, ""+limit), null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					listBloodOxygen=new ArrayList<IHealthDataList>(cursor.getCount());
					cursor.moveToFirst();
					while(!cursor.isAfterLast()){
						IHealthDataList bloodOxygenData=new IHealthDataList();
						bloodOxygenData.setBloodOxygen(cursor.getInt(1));
						bloodOxygenData.setHR(cursor.getInt(2));
						bloodOxygenData.setDate(cursor.getInt(3));
						bloodOxygenData.setLastChangeTime(cursor.getInt(4));
						listBloodOxygen.add(bloodOxygenData);
						cursor.moveToNext();
					}
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception select gluco: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return listBloodOxygen;
		
	}
	/*end: blood oxygen*/
	
	/*start: activity report*/
	public void insertActivityReport(IHealthDataList activityReportData){
		ContentValues values = new ContentValues();
		values.put(CALORIESKEY, activityReportData.getCalories());
		values.put(DISTANCETRAVELLEDKEY, activityReportData.getDistanceTraveled());
		values.put(STEPSKEY, activityReportData.getStepValue());
		values.put(MDATEKEY, activityReportData.getDate());
		values.put(LAST_CHANGEKEY, activityReportData.getLastChangeTime());
		sqldb.insert("activity_report", null, values);
	}
	
	public void clearActivityReportData(){
		if (sqldb != null && sqldb.isOpen()){
			sqldb.execSQL("DELETE FROM activity_report");
		}
	}
	
	public int getTotalActivityReport(){
		String sql="select count(*) from activity_report";
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(sql,null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					cursor.moveToFirst();
					return cursor.getInt(0);
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception getTotalactivity_report: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return 0;
	}
	
	public List<IHealthDataList> selectActivityReport(int start,int limit){
		String sql="select * from activity_report order by MDate desc limit %s,%s";
		List<IHealthDataList> listActivityReport=null;
		if (sqldb != null && sqldb.isOpen()) {
			Cursor cursor=sqldb.rawQuery(String.format(sql,""+start, ""+limit), null);
			if(cursor!=null && cursor.getCount()>0){
				try{
					listActivityReport=new ArrayList<IHealthDataList>(cursor.getCount());
					cursor.moveToFirst();
					while(!cursor.isAfterLast()){
						IHealthDataList activityReportData=new IHealthDataList();
						activityReportData.setCalories(cursor.getInt(1));
						activityReportData.setDistanceTraveled(cursor.getDouble(2));
						activityReportData.setStepValue(cursor.getInt(3));
						activityReportData.setDate(cursor.getInt(4));
						activityReportData.setLastChangeTime(cursor.getInt(5));
						listActivityReport.add(activityReportData);
						cursor.moveToNext();
					}
				}catch (Exception e) {
					// TODO: handle exception
					MyLog.d(GlobalConstant.TAG, "exception select gluco: "+e.getMessage());
				}finally{
					if(!cursor.isClosed())
						cursor.close();
				}
			}
		}
		return listActivityReport;
		
	}
	/*end: activity report*/
	
	public static CacheManager getInstance(Context context){
		if(mInstance==null){
			mInstance=new CacheManager();
			sqldb=context.openOrCreateDatabase(DATABASE_NAME,
					Context.MODE_PRIVATE, null);
			sqldb.execSQL("CREATE TABLE IF NOT EXISTS partner ( "
					+ "partnerId INTEGER PRIMARY KEY, " + "name TEXT, "
					+ "description TEXT, " + "shortDescription TEXT, "
					+ "website TEXT, " + "email TEXT, " + "phone TEXT, "
					+ "logo TEXT, " + "imageUrl TEXT,"+ "categoryId INTEGER, "+ "skypeName TEXT, "+ "priority INTEGER )");
			sqldb.execSQL("CREATE TABLE IF NOT EXISTS category_partner ( "
					+ "categoryId INTEGER PRIMARY KEY, " + "name TEXT, "
					+ "logoUrl TEXT, " + "shortDescription TEXT,"+"priority INTEGER )");
			/*start: ihealth*/
			sqldb.execSQL("CREATE TABLE IF NOT EXISTS blood_pressure ( "
					+ "Id INTEGER PRIMARY KEY AUTOINCREMENT, " + "HP INTEGER, "
					+ "LP INTEGER, " + "HR INTEGER,"+ "MDate INTEGER,"+"last_change INTEGER )");
			sqldb.execSQL("CREATE TABLE IF NOT EXISTS weight ( "
					+ "Id INTEGER PRIMARY KEY AUTOINCREMENT, " + "Weight REAL, "
					+ "BMI REAL, " + "DCI INTEGER,"+ "MDate INTEGER,"+"last_change INTEGER )");
			sqldb.execSQL("CREATE TABLE IF NOT EXISTS gluco ( "
					+ "Id INTEGER PRIMARY KEY AUTOINCREMENT, " + "BG INTEGER, "
					+ "DinnerSituation TEXT, " + "DrugSituation TEXT,"+ "MDate INTEGER,"+"last_change INTEGER )");
			sqldb.execSQL("CREATE TABLE IF NOT EXISTS blood_oxygen ( "
					+ "Id INTEGER PRIMARY KEY AUTOINCREMENT, " + "BO INTEGER, "
					+ "HR INTEGER, " + "MDate INTEGER,"+"last_change INTEGER )");
			sqldb.execSQL("CREATE TABLE IF NOT EXISTS activity_report ( "
					+ "Id INTEGER PRIMARY KEY AUTOINCREMENT, " + "Calories INTEGER, "
					+ "DistanceTraveled REAL, " + "Steps INTEGER, " + "MDate INTEGER,"+"last_change INTEGER )");
			/*end: ihealth*/
		}
		return mInstance;
	}
	
//	public void open() {
//		if (sqldb != null && sqldb.isOpen()) {
//			CacheManager.sqldb.close();
//		}
//		if (sqldb == null || !sqldb.isOpen()) {
//			sqldb = mContext.openOrCreateDatabase("telemedicine",
//					Context.MODE_PRIVATE, null);
//			sqldb.execSQL("CREATE TABLE IF NOT EXISTS partner ( "
//					+ "partnerId INTEGER PRIMARY KEY, " + "name TEXT, "
//					+ "description TEXT, " + "shortDescription TEXT, "
//					+ "website TEXT, " + "email TEXT, " + "phone TEXT, "
//					+ "logo TEXT, " + "imageUrl TEXT,"+ "categoryId INTEGER, "+ "skypeName TEXT, "+ "priority INTEGER )");
//			sqldb.execSQL("CREATE TABLE IF NOT EXISTS category_partner ( "
//					+ "categoryId INTEGER PRIMARY KEY, " + "name TEXT, "
//					+ "logoUrl TEXT, " + "shortDescription TEXT,"+"priority INTEGER )");
//			/*start: ihealth*/
//			sqldb.execSQL("CREATE TABLE IF NOT EXISTS blood_pressure ( "
//					+ "Id INTEGER PRIMARY KEY AUTOINCREMENT, " + "HP INTEGER, "
//					+ "LP INTEGER, " + "HR INTEGER,"+ "MDate INTEGER,"+"last_change INTEGER )");
//			sqldb.execSQL("CREATE TABLE IF NOT EXISTS weight ( "
//					+ "Id INTEGER PRIMARY KEY AUTOINCREMENT, " + "Weight REAL, "
//					+ "BMI REAL, " + "DCI INTEGER,"+ "MDate INTEGER,"+"last_change INTEGER )");
//			sqldb.execSQL("CREATE TABLE IF NOT EXISTS gluco ( "
//					+ "Id INTEGER PRIMARY KEY AUTOINCREMENT, " + "BG INTEGER, "
//					+ "DinnerSituation TEXT, " + "DrugSituation TEXT,"+ "MDate INTEGER,"+"last_change INTEGER )");
//			sqldb.execSQL("CREATE TABLE IF NOT EXISTS blood_oxygen ( "
//					+ "Id INTEGER PRIMARY KEY AUTOINCREMENT, " + "BO INTEGER, "
//					+ "HR INTEGER, " + "MDate INTEGER,"+"last_change INTEGER )");
//			sqldb.execSQL("CREATE TABLE IF NOT EXISTS activity_report ( "
//					+ "Id INTEGER PRIMARY KEY AUTOINCREMENT, " + "Calories INTEGER, "
//					+ "DistanceTraveled REAL, " + "Steps INTEGER, " + "MDate INTEGER,"+"last_change INTEGER )");
//			/*end: ihealth*/
//		}
//	}
}
